// (c) Copyright 2013 Stephen Gold <sgold@sonic.net>
// Distributed under the terms of the GNU General Public License

/*
 This file is part of the Bats Game.

 The Bats Game is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by the
 Free Software Foundation, either version 3 of the License, or (at your
 option) any later version.

 The Bats Game is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.

 You should have received a copy of the GNU General Public License
 along with the Bats Game.  If not, see <http://www.gnu.org/licenses/>.
 */
package bats.scene;

/**
 * Enumerate the control modes of a PointOfView (POV).
 *
 * @author Stephen Gold <sgold@sonic.net>
 */
public enum PovMode {
    // *************************************************************************
    // values

    ORBITING, FIRST_PERSON, FLYING;
    // *************************************************************************
    // constants
    /**
     * items in the "select pov" popup menu when the POV's subject is a unit
     */
    public static final String[] selectPovItemsAll = {
        "orbiting", "first-person", "flying"
    };
    /**
     * items in the "select pov" popup menu when the POV's subject isn't a unit
     */
    static final String[] selectPovItems = {
        "orbiting", "flying"
    };
    // *************************************************************************
    // new methods exposed

    /**
     * Look up the Nifty id of the radio button for this mode.
     */
    public String buttonId() {
        switch (this) {
            case ORBITING:
                return "orbitingRadioButton";
            case FIRST_PERSON:
                return "firstPersonRadioButton";
            case FLYING:
                return "flyingRadioButton";
        }
        return "?";
    }

    /**
     * Look up the textual description of this mode.
     */
    public String describe() {
        switch (this) {
            case ORBITING:
                return "orbiting";
            case FIRST_PERSON:
                return "first-person";
            case FLYING:
                return "flying";
        }
        return "?";
    }

    /**
     * Find a mode based on its textual description.
     *
     * @param description
     */
    static PovMode fromDescription(String description) {
        for (PovMode mode : PovMode.values()) {
            if (mode.describe().equals(description)) {
                return mode;
            }
        }
        return null;
    }

    /**
     * Look up the Nifty id of the radio button label for this mode.
     */
    public String labelId() {
        switch (this) {
            case ORBITING:
                return "orbitingLabel";
            case FIRST_PERSON:
                return "firstPersonLabel";
            case FLYING:
                return "flyingLabel";
        }
        return "?";
    }
}